'use strict';
//基础配置
module.exports = {
    //Session对象存储特定用户会话所需的属性及配置信息
    seesion:{
        key:'koa-sess',
        maxAge:86400000,
        overwrite:true,
        httpOnly:true,
        signed:true,
        rolling:false,
        renew:false,
    },
    cors:{
        origin:function(ctx){
            const whiteList = ['http://localhost:8000'];
            console.log("host:"+ctx.request.url)
            console.log("referer:"+ctx.header.referer)
            let url = ctx.request.url;
            if(ctx.header.referer){
                url = ctx.header.referer.substr(0,ctx.header.referer.length -1)
            }
            if(whiteList.includes(url)){
                console.log("判断正确")
                return url;
            }
            return 'http://localhost:8080';
        },
        maxAge:5,
        credentials:true,
        allowMethods:['GET','POST','PUT','DELETE','OPTIONS'],
        allowHeader:['Content- type','Authorization','Accept'],
        exposeHeader:['WWW-Authenticate','Server-Authorization']
    },
    jwt:{
        secretKey:'myAppToken',
        tokenExpiresTime:1000*60//token过期时间
    }
}